package com.newcoder.huawei;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * 输入：
 * 4
 * 0 1
 * 0 2
 * 1 2
 * 3 4
 * <p>
 * 输出：
 * 0 3
 * 1 2
 * 3 4
 */
public class HJ8 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int mapLength = Integer.parseInt(in.nextLine());
        Map<Integer, Integer> integerMap = new HashMap<>();
        int recordKey = -1;
        int index = 0;
        while (in.hasNext()) { // 注意 while 处理多个 case
            String kvstr = in.nextLine();
            String[] kvArray = kvstr.split(" ");
            int key = Integer.valueOf(kvArray[0]);
            int val = Integer.valueOf(kvArray[1]);
            if (key == recordKey && index>0) {
                val = integerMap.get(key)+key;
                integerMap.put(key, val);
            } else {
                integerMap.put(key, val);
            }
            recordKey = key;
            index++;
        }
        System.out.println(integerMap);
    }
}
